package com.jdwx.opengl.kotlin

fun main(){

//    val numbers = listOf("one", "two", "three", "four")
//    numbers.filter { it.length > 3 }  // `numbers` 没有任何改变，结果丢失
//    println("numbers are still $numbers")
//    val longerThan3 = numbers.filter { it.length > 3 } // 结果存储在 `longerThan3` 中
//    println("numbers longer than 3 chars are $longerThan3")


    val numbers = listOf("one", "two", "three", "four")
    val filterResults = mutableListOf<String>()  // 目标对象
    numbers.filterTo(filterResults) { it.length > 3 }
    println(filterResults) // 包含两个操作的结果
    numbers.filterIndexedTo(filterResults) { index, _ -> index == 0 }
    println(filterResults) // 包含两个操作的结果


    val colors = listOf("red", "brown", "grey")
    val animals = listOf("fox", "bear", "wolf")

    println(colors.zip(animals) { color1, animal1 -> "The ${animal1.capitalize()} is $color1"})

    val numberPairs = listOf("one" to 1, "two" to 2, "three" to 3, "four" to 4)
    println(numberPairs.unzip())

    var unzip = numberPairs.unzip()

    println( unzip.first.get(1) )




}